export function binarySearch (arr, target) {
  return _binarySearch(arr, target, 0, arr.length - 1)
}

function _binarySearch (arr, target, left, right) {
  if (left > right) {
    return -1
  }
  const mid = parseInt(left + (right - left) / 2)
  if (arr[mid] === target) {
    return mid
  } else if (arr[mid] > target) {
    return _binarySearch(arr, target, left, mid - 1)
  } else {
    return _binarySearch(arr, target, mid + 1, right)
  }
}

// export default binarySearch
export default { binarySearch }
